//
//  testViewController.m
//  lvtu
//
//  Created by Apple on 12-3-28.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "testViewController.h"
#import "UserInfo.h"
#import "DataSource.h"

@implementation testViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSDictionary* info = [[NSDictionary alloc] initWithObjectsAndKeys:@"martin.szj@gmail.com",@"email",@"123456",@"password",
                          [[DataSource shareInstance] sys_getOSVersion],@"os",
                          LVTU_CLIENT_VERSION,@"version",
                          LVTU_CHANNEL,@"channel",
                          [[DataSource shareInstance] sys_getDeviceModelName],@"device_name",
                          [[DataSource shareInstance] sys_getDeviceID],@"device_id",
                          @"1",@"is_iphone",
                          nil];
    CoreMsg* msg = [[CoreMsg alloc] init];
    msg.data = LOGININFO;
    msg.ui_delegate = self;
    
    [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=page_o_login" postInfo:info userInfo:msg];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
//    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return NO;
}


- (void)onDataSourceSucCallback:(CoreMsg *)coreMsg withData:(id)data
{
    if ([coreMsg.data isEqual: LOGININFO]) {
//        CoreMsg* msg = [[CoreMsg alloc] init];
//        msg.data = RECOMMENDINFO;
//        msg.ui_delegate = self;
//        
//        [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=page_recommend_line" postInfo:nil userInfo:msg];
        
//        NSDictionary* info = [[NSDictionary alloc] initWithObjectsAndKeys:@"2012-03-04",@"start_time",@"2012-03-05",@"end_time",@"第一旅",@"name",@"image",@"",nil];
//        CoreMsg* msg = [[CoreMsg alloc] init];
//        msg.data = CREATTRIP;
//        msg.ui_delegate = self;
//        
//        [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=do_creat_line" postInfo:info userInfo:msg];
        
//        CoreMsg* msg = [[CoreMsg alloc] init];
//        msg.data = CITYLIST;
//        msg.ui_delegate = self;
//             
//        [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=page_city_list" postInfo:nil userInfo:msg];
        
//        NSDictionary* info = [[NSDictionary alloc] initWithObjectsAndKeys:@"1",@"c_city_id",@"1",@"element_type",nil];
//        CoreMsg* msg = [[CoreMsg alloc] init];
//        msg.data = ELEMENTSEARCH;
//        msg.ui_delegate = self;
//                
//        [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=page_element_search" postInfo:info userInfo:msg];
        
        
//        NSDictionary* info = [[NSDictionary alloc] initWithObjectsAndKeys:@"4",@"c_travel_line_id",nil];
//        CoreMsg* msg = [[CoreMsg alloc] init];
//        msg.data = TRAVELDETAIL;
//        msg.ui_delegate = self;
//        
//        [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=page_line_detail" postInfo:info userInfo:msg];
        
        NSDictionary* info = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"page",@"0",@"keyword",nil];
        CoreMsg* msg = [[CoreMsg alloc] init];
        msg.data = MYTRIP;
        msg.ui_delegate = self;
        
        [[NetDataSource shareInstance]postTo:@"http://www.wxlvtu.com/?a=page_my_line" postInfo:info userInfo:msg];
    }
}

- (void)onDataSourceFailCallback:(CoreMsg *)coreMsg withData:(id)data
{
    if ([data isKindOfClass:[UserInfo class]]) {
        
    }
}

@end
